<?php
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP
 *
 * This content is released under the MIT License (MIT)
 *
 * Copyright (c) 2014 - 2017, British Columbia Institute of Technology
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * @package	CodeIgniter
 * @author	EllisLab Dev Team
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 * @copyright	Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/)
 * @license	http://opensource.org/licenses/MIT	MIT License
 * @link	https://codeigniter.com
 * @since	Version 1.0.0
 * @filesource
 */
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Config Class
 *
 * This class contains functions that enable config files to be managed
 *
 * @package		CodeIgniter
 * @subpackage	Libraries
 * @category	Libraries
 * @author		EllisLab Dev Team
 * @link		https://codeigniter.com/user_guide/libraries/config.html
 */
class MY_Config extends CI_Config {

	public function __construct()
	{
		parent::__construct();
		
		log_message('debug', "MY_Config Class Initialized.");
	}
	// --------------------------------------------------------------------

	/**
	 * Site name
	 * Returns base_name 
	 *
	 * @access	public
	 * @param	string	the URI string
	 * @return	string
	 */
	function site_web_name($uri = '')
	{
		
		if($uri == '')
		{
			return $this->item('web_name');
		}else
		{
			return $uri . " - " . $this->item('web_name');
		}
	}

	
	/**
	 * Site keyword
	 * Returns base_keyword 
	 *
	 * @access	public
	 * @param	string	the URI string
	 * @return	string
	 */
	function site_web_keyword($uri = '')
	{
		if($uri == '')
		{
			return $this->item('web_keyword');
		}else
		{
			return $this->item('web_keyword')." ".$uri;
		}
	}

	
	
	/**
	 * Site description
	 * Returns base_description 
	 *
	 * @access	public
	 * @param	string	the URI string
	 * @return	string
	 */
	function site_web_description($uri = '')
	{
		if($uri == '')
		{
			return $this->item('web_description');
		}else
		{
			return $this->item('web_description')." ".$uri;
		}
	}

	
	
	function get_ico_url()
	{
		return $this->base_url($this->item('web_ico'));
	}
	
	
	
	//
	function get_web_url($type = NULL, $uri = NULL, $mark='')
	{
		$url_arr = $this->item('web_url');
		if($url_arr == NULL || $type == NULL)
		{
			return $uri;
		}
		if($mark == NULL)
		{
			return rtrim($url_arr[trim($type)],'/') . '/' . trim($uri,'/');
		}
		else
		{
			return rtrim($url_arr[trim($type)],'/') . '/' .trim($mark,'/') .'/'. trim($uri,'/');
		}
	}
	
}
